//
// Created by Administrator on 2024/3/17.
//
// O(nlog(n))贪心策略
#include<bits/stdc++.h>

using namespace std;


using ll = long long;
#define endl '\n'

int w, n;
int a[30000], book[30000];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> w >> n;
    int j = n - 1;
    for (int i = 0; i < n; i++)cin >> a[i];
    sort(a, a + n);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (book[i] == 1)continue;
        ++cnt;
        book[i] = 1;
        for (; j > i; j--) {
            if (book[j] == 1)continue;
            if (a[i] + a[j] <= w) {
                book[j] = 1;
                break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}